package org.ccay.enumerable;

import org.ccay.enumerable.EnumI18nUtil;
import org.ccay.enumerable.EnumItem;

public enum SourceEnum implements EnumItem{
	SOURCE_JAVA("SourceCode","源代码"),
	SOURCE_XML("XmlFile","XML文件"),
	SOURCE_DB("Database","数据库");
	
	private String value;
	private String displayValue;

	private SourceEnum(String value, String displayValue){
		this.value = value;
		this.displayValue = displayValue;
	}
	
	@Override
	public String getType() {
		return this.getClass().getSimpleName();
	}

	@Override
	public int getIndex() {
		return ordinal();
	}

	@Override
	public String getName() {
		return this.name();
	}

	@Override
	public String getValue() {
		return value;
	}

	@Override
	public String getDisplayValue() {
		return displayValue;
	}

	@Override
	public String getSource() {
		return SOURCE_JAVA.getValue();
	}

	@Override
	public String getDisplayValue(String language) {
		return EnumI18nUtil.getI18nName(this, language);
	}
	public EnumItem<SourceEnum> fromValue(String value) {
		return EnumUtil.getInstance().getByTypeValue(getType(),  getValue());
	}
}
